//
//  ChangeThePasswordVC.m
//  EJLX
//
//  Created by adc on 15/11/9.
//  Copyright © 2015年 江苏一键联信息科技有限公司. All rights reserved.
//

#import "ChangeThePasswordVC.h"
#import "HttpsManager.h"
#import "XiuGaiMiMa.h"
@interface ChangeThePasswordVC ()

@end

@implementation ChangeThePasswordVC

- (void)viewDidLoad {
    [super viewDidLoad];
   // self.navigationController.navigationBarHidden = NO;
   // self.title = @"修改密码";
    UIView*viewbg=[[UIView alloc]initWithFrame:CGRectMake(0, 20,WIDE , 44)];
    viewbg.backgroundColor=RGB_COLOR(0x00c49f);
    [self.view addSubview:viewbg];
    UILabel*label=[[UILabel alloc]initWithFrame:CGRectMake(WIDE/2-35,7, 70,30)];
    label.text=@"修改密码";
    label.textAlignment=NSTextAlignmentCenter;
    label.textColor=[UIColor whiteColor];
    [viewbg addSubview:label];
    UIButton*but1=[[UIButton alloc]initWithFrame:CGRectMake(10,7,30, 30)];
    [but1 setImage:[UIImage imageNamed:@"返回箭头"] forState:UIControlStateNormal];
    [but1 addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
    [viewbg addSubview:but1];
    UIImageView*bgImage=[[UIImageView alloc]initWithFrame:CGRectMake((WIDE-150)/2,70,150, 140)];
    bgImage.image=[UIImage imageNamed:@"login"];
    [self.view addSubview:bgImage];

    UIView *View1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0,30,40)];
    
    UIImageView*viewImage1=[[UIImageView alloc]initWithFrame:CGRectMake(8,10,17,20)];
   
    [viewImage1 setImage:[UIImage imageNamed:@"用户图标"]];
    [View1 addSubview:viewImage1];
   _phone.leftView=View1;
    
    _phone.leftViewMode=UITextFieldViewModeAlways;
    [_phone setLeftViewMode:UITextFieldViewModeAlways];

    UIView *View2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0,30,40)];
    
    UIImageView*viewImage2=[[UIImageView alloc]initWithFrame:CGRectMake(8,10,17,20)];
    
    [viewImage2 setImage:[UIImage imageNamed:@"密码图标"]];
    [View2 addSubview:viewImage2];
     _passWord.leftView=View2;
    
    _passWord.leftViewMode=UITextFieldViewModeAlways;
    [_passWord setLeftViewMode:UITextFieldViewModeAlways];
    
    UIView *View3 = [[UIView alloc] initWithFrame:CGRectMake(0, 0,30,40)];
    
    UIImageView*viewImage3=[[UIImageView alloc]initWithFrame:CGRectMake(8,10,17,20)];
    
    [viewImage3 setImage:[UIImage imageNamed:@"密码图标"]];
    [View3 addSubview:viewImage3];
    _aginePassWord.leftView=View3;
    
    _aginePassWord.leftViewMode=UITextFieldViewModeAlways;
    [_aginePassWord setLeftViewMode:UITextFieldViewModeAlways];
    
    UIView *View4 = [[UIView alloc] initWithFrame:CGRectMake(0, 0,30,40)];
    
    UIImageView*viewImage4=[[UIImageView alloc]initWithFrame:CGRectMake(8,10,17,20)];
    
    [viewImage4 setImage:[UIImage imageNamed:@"手机验证码"]];
    [View4 addSubview:viewImage4];
    _yanZhengMa.leftView=View4;
    
    _yanZhengMa.leftViewMode=UITextFieldViewModeAlways;
    [_yanZhengMa setLeftViewMode:UITextFieldViewModeAlways];
    UIView *View5 = [[UIView alloc] initWithFrame:CGRectMake(0, 0,110,40)];
    UIButton*but=[[UIButton alloc]initWithFrame:CGRectMake(0,5,100,30)];
    //[but.imageView=view5];
    [but setTitle:@"获取验证码" forState:UIControlStateNormal];
    [but setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [but setBackgroundColor:RGB_COLOR(0x00c49f)];
    but.layer.cornerRadius=5;
    //[but setImage:[UIImage imageNamed:@"获取验证码"] forState:UIControlStateNormal];
    but.font=[UIFont systemFontOfSize:15];
    [but addTarget:self action:@selector(butClick) forControlEvents:UIControlEventTouchUpInside];
    [View5 addSubview:but];
    _yanZhengMa.rightView=View5;
    
    _yanZhengMa.rightViewMode=UITextFieldViewModeAlways;
    [_yanZhengMa setLeftViewMode:UITextFieldViewModeAlways];
}

-(void)butClick
{
    
  

    [HttpsManager requestGetShouJiYanZhengMa:_phone.text compeletion:^(int errcode, NSString *errmsg)
     {
         NSString*str=[NSString stringWithFormat:@"%d",errcode];
         if ([str isEqualToString:@"0"])
         {
             
             SHOW_ALERT(errmsg);
             //HomeVC*vc=[[HomeVC alloc]init];
             //[self.navigationController pushViewController:vc animated:YES];
             // [self.navigationController popViewControllerAnimated:YES];
             return ;
         }
         
         SHOW_ALERT(errmsg);
         
         
     }];
          

}
-(void)backClick
{
    
    [self.navigationController popViewControllerAnimated:YES];
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/


- (IBAction)queRen:(UIButton *)sender {
//    
//    JGProgressHUD *HUD = [[JGProgressHUD alloc] initWithStyle:JGProgressHUDStyleDark];
//    
//    
//    HUD.useProgressIndicatorView = YES;
//    
//    [HUD showInView:self.navigationController.view];
//    if ([_passWord.text isEqualToString:@""]) {
//        HUD.textLabel.text = @"密码不能为空！";
//        [HUD dismissAfterDelay:0.3];
//    }else{
//        if (_passWord.text.length<6||_passWord.text.length>12) {
//            
//            
//            HUD.textLabel.text = @"请输入长度6到12位的密码!";
//            [HUD dismissAfterDelay:0.3];
//            
//        }else{
//            
//            if(_passWord.text !=_aginePassWord.text) {
//                HUD.textLabel.text = @"密码不符,请检查后重新输入！";
//                [HUD dismissAfterDelay:0.3];
//            }else{
    
    XiuGaiMiMa*xiuGai=[[XiuGaiMiMa alloc]init];
    xiuGai.password= [MD5 md532BitLower:_passWord.text];
    xiuGai.phone=_phone.text;
    xiuGai.captcha=_yanZhengMa.text;
    [HttpsManager requestXiuGaiMiMaXiuGai:xiuGai compeletion:^(int errcode, NSString *errmsg, NSString *token)
     {
         NSString*str=[NSString stringWithFormat:@"%d",errcode];
         if ([str isEqualToString:@"0"])
         {
             SHOW_ALERT(errmsg);
             
         }
         [self.navigationController popViewControllerAnimated:YES];
     }];

         //   }}}
}
@end
